Simple, Composable Patterns for LLM Systems
Over the past year, we've worked with dozens of teams building large language model (LLM) agents across industries. Consistently, the most successful implementations weren't using complex frameworks or specialized libraries. Instead, they were building with simple, composable patterns.
In this presentation, we share what we've learned from working with customers and building agents ourselves, and give practical advice for developers on building effective agents.
"Agent" can be defined in several ways. At Anthropic, we categorize all these variations as agentic systems, but draw an important architectural distinction:
Systems where LLMs and tools are orchestrated through predefined code paths.
Systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.
Below, we will explore both types of agentic systems in detail.
When building applications with LLMs, we recommend finding the simplest solution possible, and only increasing complexity when needed. This might mean not building agentic systems at all.
There are many frameworks that make agentic systems easier to implement, including:
The basic building block of agentic systems is an LLM enhanced with augmentations such as retrieval, tools, and memory. Our current models can actively use these capabilities—generating their own search queries, selecting appropriate tools, and determining what information to retain.
We recommend focusing on two key aspects: tailoring these capabilities to your specific use case and ensuring they provide an easy, well-documented interface for your LLM.
Prompt chaining decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one. You can add programmatic checks on any intermediate steps to ensure that the process is still on track.
Ideal for situations where the task can be easily and cleanly decomposed into fixed subtasks. The main goal is to trade off latency for higher accuracy, by making each LLM call an easier task.
Routing classifies an input and directs it to a specialized followup task. This workflow allows for separation of concerns, and building more specialized prompts.
Works well for complex tasks where there are distinct categories that are better handled separately, and where classification can be handled accurately.
LLMs can sometimes work simultaneously on a task and have their outputs aggregated programmatically. This workflow manifests in two key variations:
Breaking a task into independent subtasks run in parallel.
Running the same task multiple times to get diverse outputs.
Effective when subtasks can be parallelized for speed, or when multiple perspectives are needed for higher confidence results.
In the orchestrator-workers workflow, a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results.
Well-suited for complex tasks where you can't predict the subtasks needed. The key difference from parallelization is its flexibility—subtasks aren't pre-defined, but determined by the orchestrator.
Coding products that make complex changes to multiple files each time.
In the evaluator-optimizer workflow, one LLM call generates a response while another provides evaluation and feedback in a loop.
Particularly effective when we have clear evaluation criteria, and when iterative refinement provides measurable value. This is analogous to the iterative writing process a human writer might go through.
Agents are emerging in production as LLMs mature in key capabilities—understanding complex inputs, engaging in reasoning and planning, using tools reliably, and recovering from errors.
Note: The autonomous nature of agents means higher costs, and the potential for compounding errors. We recommend extensive testing in sandboxed environments.
These building blocks aren't prescriptive. They're common patterns that developers can shape and combine to fit different use cases.
As with any LLM features, measuring performance and iterating on implementations is crucial. You should consider adding complexity only when it demonstrably improves outcomes.
Frameworks can help you get started quickly, but don't hesitate to reduce abstraction layers and build with basic components as you move to production.
Success in the LLM space isn't about building the most sophisticated system. It's about building the right system for your needs.
Our work with customers has revealed two particularly promising applications for AI agents that demonstrate the practical value of the patterns discussed above.
A natural fit for more open-ended agents because:
Particularly effective because:
No matter which agentic system you're building, tools will likely be an important part of your agent. Tool definitions and specifications should be given just as much prompt engineering attention as your overall prompts.